from django.db import models

from api.utils.enums import BasketType


class Basket(models.Model):
    user = models.ForeignKey("User", on_delete=models.CASCADE, related_name="baskets")
    type = models.CharField(
        help_text="购物车类型",
        choices=BasketType.to_choices(),
        default=BasketType.BEFOR.value,
        max_length=256,
    )


class BasketLines(models.Model):
    basket = models.ForeignKey(Basket, on_delete=models.CASCADE, related_name="lines")
    product = models.ForeignKey("Product", on_delete=models.CASCADE, related_name="basket_lines")
    quantity = models.PositiveIntegerField(help_text="数量", default=0)
    price = models.PositiveIntegerField(help_text="商品总价", default=0)
